package com.cz.basetool.ui_work.util.et_bind;


import android.util.Pair;

import com.cz.basetool.ui_work.util.txt.CZ_TextUtil;
import com.cz.basetool.ui_work.util.txt.RegularUtil;
import com.cz.basetool.ui_work.util.et_bind.base.BaseEditTextValidator;

/**
 * Created by 陈章 on 2017/4/12 0012.
 * func:
 * 邮寄地址校验器
 */
public class EmailAddressValidator extends BaseEditTextValidator {
    public EmailAddressValidator() {
    }

    public EmailAddressValidator(OnValidatorResultObserver validatorResultObserver) {
        super(validatorResultObserver);
    }

    @Override
    public Pair validate(String txt) {
        if(CZ_TextUtil.is_null_or_empty(txt)){
            return new Pair(false,"不能为空");
        }

        boolean check = RegularUtil.check(txt, "/^[\\u4e00-\\u9fa5a-zA-Z0-9\\-\\、]+$/");
        if(check == true) {
            return  getRightPair();
        }else{
            return getErrorPair("邮寄地址格式不正确");
        }
    }
}
